class <%= @controller_name.capitalize %>Controller < RIPController
  
  <% @dependent_entity.each do |entity| %>
  
  # Show all <%= entity.pluralize %> for a particular <%= @controller_name %>
  # HTTP GET at /<%= @controller_name %>/1/<%= entity %>
  get "/:id/<%= entity %>/?" do
    @<%= entity.pluralize %> = <%= @controller_name.capitalize %>.get(params[:id]).<%= entity.pluralize %>
    #to_xml(@<%= @controller_name %>)
	  to_html(:index,"<%= entity %>")
  end
  
  # Show a page where you can fill in details for adding a new <%= entity %> for a <%= @controller_name %>
  # HTTP GET at /<%= @controller_name %>/1/<%= entity %>/new
  get "/:id/<%= entity %>/new" do
    @<%= entity %> = <%= entity.capitalize %>.new
	  to_html(:new, "<%= entity %>")
  end

  # Show the edit page for a particular <%= entity %> of a <%= @controller_name %>
  # HTTP GET at /<%= @controller_name %>/1/<%= entity %>/1/edit
  get "/:id/<%= entity %>/:id2/edit" do
    @<%= entity %> = <%= @controller_name.capitalize %>.get(params[:id]).<%= entity.pluralize %>.get(params[:id2])
    #to_xml(@<%= @controller_name %>)
	  to_html(:edit, "<%= entity %>")
  end
  
  # Add a new <%= entity %> for a particular <%= @controller_name %>
  # HTTP POST at /<%= @controller_name %>/1/<%= entity %>
  post "/:id/<%= entity %>" do
    @<%= entity %> = <%= entity.capitalize %>.new
    @<%= entity %>.attributes = params[:<%= entity %>]
    @<%= entity %>.save
    #to_xml(@<%= entity %>)
	  to_html(:show, "<%= entity %>")
  end
  
  # Edit a particular <%= entity %> for a <%= @controller_name %>
  # HTTP PUT at /<%= @controller_name %>/1/<%= entity %>/1
  put "/:id/<%= entity %>/:id2/?" do
    @<%= entity %> = <%= @controller_name.capitalize %>.get(params[:id]).<%= entity.pluralize %>.get(params[:id2])
    @<%= entity %>.update(params[:<%= entity %>])
    #to_xml(@<%= entity %>)
	  to_html(:show, "<%= entity %>")
  end
  
  # Delete a particular <%= entity %> for a <%= @controller_name %>
  # HTTP DELETE at /<%= @controller_name %>/1/<%= entity %>/1
  delete "/:id/<%= entity/:id2 %>" do
    @<%= entity %> = <%= entity.capitalize %>.get(params[:id]).<%= entity.pluralize %>.get(params[:id2])
    @<%= entity %>.destroy!
    #to_xml(<%= entity %>)
	  to_html(:index, "<%= entity %>")
  end
  <% end %>

  # Shows list of all <%= @controller_name.pluralize %>
  # HTTP GET at /<%= @controller_name %>
  get "/?" do
    @<%= @controller_name.pluralize %> = <%= @controller_name.capitalize %>.all
    #to_xml(@<%= @controller_name.pluralize %>)
	  to_html(:index)
  end

  # Show a page where you can fill in details for adding a new <%= @controller_name %>
  # HTTP GET at /<%= @controller_name %>/new
  get "/new" do
    @<%= @controller_name %> = <%= @controller_name.capitalize %>.new
	  to_html(:new)
  end

  # Show a particular <%= @controller_name %>
  # HTTP GET at /<%= @controller_name %>/1
  get "/:id" do
    @<%= @controller_name %> = <%= @controller_name.capitalize %>.get(params[:id])
    #to_xml(@<%= @controller_name %>)
	  to_html(:show)
  end
  
  # Show the edit page for a particular <%= @controller_name %>
  # HTTP GET at /<%= @controller_name %>/1/edit
  get "/:id/edit" do
    @<%= @controller_name %> = <%= @controller_name.capitalize %>.get(params[:id])
    #to_xml(@<%= @controller_name %>)
	  to_html(:edit)
  end

  
  # Add a new <%= @controller_name %>
  # HTTP POST at /<%= @controller_name %>
  post "/?" do
    @<%= @controller_name %> = <%= @controller_name.capitalize %>.new
    @<%= @controller_name %>.attributes = params[:<%= @controller_name %>]
    @<%= @controller_name %>.save
    #to_xml(@<%= @controller_name %>)
	  to_html(:show)
  end
  
  # Edit a <%= @controller_name %>
  # HTTP PUT at /<%= @controller_name %>/1
  put "/:id/?" do
    @<%= @controller_name %> = <%= @controller_name.capitalize %>.get(params[:id])
    @<%= @controller_name %>.update(params[:<%= @controller_name %>])
    #to_xml(@<%= @controller_name %>)
	  to_html(:show)
  end

  
  # Delete a <%= @controller_name %>
  # HTTP DELETE at /<%= @controller_name %>/1
  delete "/:id" do
    @<%= @controller_name %> = <%= @controller_name.capitalize %>.get(params[:id])
    @<%= @controller_name %>.destroy!
    #to_xml(<%= @controller_name %>)
	  to_html(:index)
  end

end